﻿Imports System
Imports System.Collections.Generic
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Windows.Media.Imaging
Imports System.Windows.Navigation
Imports System.Windows.Shapes

Namespace Views
    Partial Public Class ViewSimulationResult
        Public Sub New()
            MyBase.New()

            Me.InitializeComponent()

            ' Insert code required on object creation below this point.
        End Sub

        Private Sub DataGrid1_AutoGeneratingColumn(ByVal sender As System.Object, ByVal e As System.Windows.Controls.DataGridAutoGeneratingColumnEventArgs) Handles DataGrid1.AutoGeneratingColumn
        
        End Sub

        Private Sub DataGrid1_AutoGeneratedColumns(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.AutoGeneratedColumns
            Dim q = From elt In DataGrid1.Columns Where elt.Header.ToString() = "TRI" Select elt

            If q.FirstOrDefault() IsNot Nothing Then
                Dim c = q.FirstOrDefault()
                Dim cb As DataGridBoundColumn = c
                cb.Binding.StringFormat = "0.00%"
                Dim s = New Style()
                s.Setters.Add( _
                    New Setter(Control.HorizontalAlignmentProperty, _
                                 HorizontalAlignment.Right))
                cb.ElementStyle = s
            End If

            For Each c In DataGrid1.Columns
                If c.Header.ToString() = "VAN" Then
                    Dim cb As DataGridBoundColumn = c
                    cb.Binding.StringFormat = "#,#"
                    Dim s = New Style()
                    s.Setters.Add( _
                        New Setter(Control.HorizontalAlignmentProperty, _
                                     HorizontalAlignment.Right))
                    cb.ElementStyle = s
                    Exit For
                End If
            Next

            DataGrid1.Language = Markup.XmlLanguage.GetLanguage("fr-FR")

        End Sub

        Private Sub DataGrid2_AutoGeneratingColumn(ByVal sender As System.Object, ByVal e As System.Windows.Controls.DataGridAutoGeneratingColumnEventArgs)
            If e.PropertyName.StartsWith("rel_") Then
                e.Cancel = True
            End If
        End Sub
    End Class
End Namespace